package com.yanggu.scala.chapater12.execrise

object MatchExercise02 {

  def main(args: Array[String]): Unit = {
    for (c <- "+-3!") {
      var sign = 0
      var digit = 0
      c match {
        //case 分支语句一旦匹配上, 就会立即停止, 不往下执行, 不用写break语句
        case _ if c > 1000 => digit = 3
        case '+' => sign = 1
        case '-' => sign = -1
        case _ => println("没有任何匹配")
      }
      println(c + "\t" + sign + "\t" + digit)
    }
  }

}
